package net.maku.jw.entity;

import lombok.Data;
import org.springframework.boot.context.properties.bind.DefaultValue;

import java.util.ArrayList;
import java.util.List;

/**
 * @author :WaiterXiaoYY
 * @description: TODO
 * @data :2020/12/17 9:27
 */
@Data
public class Course {
    private String studentid;
    private String coureseid;
    private String course;
    private String teacher;
    private String address;


    //课程性质	课程属性
    private String courseCatefory;
    private String courseAttribute;
    private String team;//学期

    private int session; //上课时间
    private int sessionCount;//上课节数

    private int week; //星期几上课
    private List<Integer> weeks;
    private String weekss;//数据库存字符类型
    private String rawWeeks;  // 1-18
    private String rawSection; //[9-10节]

    public Course(String studentid,String team,String course, String teacher, int session, int week, List<Integer> weeks, String rawWeeks, String rawSection,String address) {
        this.studentid = studentid;
        this.team = team;
        this.course = course;
        this.teacher = teacher;
        this.session = session;
        this.sessionCount = 2; //默认一次两节课 以后有需求再改
        this.week = week;
        this.weeks = weeks;
        this.rawWeeks = rawWeeks;
        this.rawSection = rawSection;
        this.address = address;
        this.weekss = listtoString(weeks);
    }

    public Course() {
    }

    String listtoString(List<Integer> weeks) {
        String str="";
        int size = weeks.size();
        for (int i = 0; i < size; i++) {
            if (i==size-1)
                str += weeks.get(i);
            else
                str = str + weeks.get(i) +",";
        }
        return str;
    }

    public List<Integer> stringtoList(String str) {
        List<Integer> weeks = new ArrayList<>();
        String[] split = str.split(",");
        for (String s : split) {
            weeks.add(Integer.valueOf(s));
        }
        return weeks;
    }


}
